package com.xb.cloud.front.client;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xb.cloud.front.common.FrontCategoryService;
import com.xb.cloud.gateway.client.Adapter;
import com.xb.cloud.gateway.client.AdapterContext;
import com.xb.cloud.gateway.client.RtnInfo;
/**
 * 
 * @ClassName:  FrontCategoryAdapter   
 * @Description:TODO
 * @author: 鲜备科技
 * @date:   2018年1月8日 上午11:10:53   
 *     
 * @Copyright: 2018 www.xianbeitech.com Inc. All rights reserved. 
 *
 */
@Component
public class FrontCategoryAdapter extends Adapter {
	
	@Autowired
	FrontCategoryService frontCategoryService;
	
	@Override
	public RtnInfo execute(String urlPath, Boolean isLogined, Map<String, String> bizInfo, AdapterContext adapterContext) {
		//获取首页类目（广告位下面的类目）
		if(urlPath.trim().toLowerCase().equals("/h5/category/front")) {
			
			RtnInfo frontCategory = frontCategoryService.getFrontCategory(adapterContext.getCompanyId());
			return frontCategory;
		} 
		//获取列表页的导航类目
		else if (urlPath.trim().toLowerCase().equals("/h5/category/navigation")) {
			RtnInfo navCategory = frontCategoryService.getNavCategory(adapterContext.getCompanyId());
			return navCategory;
		}
		return null;
	}

	@Override
	public String getUrlMappingPath() {
		
		return "/h5/category/**";
	}

}
